package Viewer;

import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;

/**
 * The WiggleInfoWindow is used to show values  of the wiggle plot on hovered positions.<br>
 * It is a simple window containing a label which can be filled with text.
 * 
 * @author Stefan Lorenz<br>
 * <br>29.11.2012
 */
@SuppressWarnings("serial")
public class WiggleInfoWindow extends JWindow implements MouseListener {

    /**
     * Internal label of the tool tip
     */
    private JLabel label;

    public WiggleInfoWindow() {
	this.addMouseListener(this);
	JPanel panel = new JPanel();
	panel.setBorder(BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
	this.label = new JLabel();
	panel.add(label);

	this.add(panel);
	this.pack();
    }

    /**
     * Sets a text to the tool tip
     * @param s text to set
     */
    public void setText(String s) {
	this.label.setText(s);
	this.label.revalidate();
	this.label.repaint();
	 this.setPreferredSize(new Dimension(this.label.getWidth()+10, 25));
	pack();
    }

    /* (non-Javadoc)
     * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
     */
    public void mouseClicked(MouseEvent arg0) {
	this.setVisible(false);
    }

    /* (non-Javadoc)
     * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
     */
    public void mouseEntered(MouseEvent arg0) {
    }

    /* (non-Javadoc)
     * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
     */
    public void mouseExited(MouseEvent arg0) {
    }

    /* (non-Javadoc)
     * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
     */
    public void mousePressed(MouseEvent arg0) {
    }

    /* (non-Javadoc)
     * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
     */
    public void mouseReleased(MouseEvent arg0) {
    }

}
